package org.cskt.sl.sys.service.impl;

import java.util.List;

import org.cskt.sl.sys.dao.GoodsMapper;
import org.cskt.sl.sys.entity.Goods;
import org.cskt.sl.sys.example.GoodsExample;
import org.cskt.sl.sys.service.GoodsService;
import org.cskt.sl.util.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class GoodsServiceImpl implements GoodsService {
	@Autowired
	private GoodsMapper goodsMapper;

	@Override
	public int countByExample(GoodsExample example) {
		// TODO Auto-generated method stub
		return goodsMapper.countByExample(example);
	}

	@Override
	public int deleteById(Integer gid) {
		// TODO Auto-generated method stub
		return goodsMapper.deleteByPrimaryKey(gid);
	}

	@Override
	public int addGoods(Goods record) {
		// TODO Auto-generated method stub
		return goodsMapper.insertSelective(record);
	}

	@Override
	public List<Goods> findGoodsPageList(GoodsExample example, Pager pager) {
		// TODO Auto-generated method stub
		return goodsMapper.selectByExample(example, (pager.getCurrentPage()-1)*pager.getPageSize(), pager.getCurrentPage()*pager.getPageSize());
	}

	@Override
	public Goods getGoodsById(Integer gid) {
		// TODO Auto-generated method stub
		return goodsMapper.selectByPrimaryKey(gid);
	}

	@Override
	public int updateGoodsById(Goods record) {
		// TODO Auto-generated method stub
		return goodsMapper.updateByPrimaryKey(record);
	}

}
